//
//  DynamicDetailViewController.m
//  BigJoy
//
//  Created by Rowling on 2017/7/17.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "DynamicDetailViewController.h"
#import "DetialHeadCell.h"
#import "DetailImageCell.h"
#import "DetailButtonCell.h"
#import "DetailPinlunCell.h"

@interface DynamicDetailViewController ()

@end

@implementation DynamicDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUI];
    self.baseDataArray = @[@"numberOfRowsInSectionnumberOfRowsInSection",
                           @"numberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSection",@"numberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSection",@"numberOfRowsInSection",@"numberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSection",@"numberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSectionnumberOfRowsInSection"];
    [self.baseMutableDataArray addObjectsFromArray:@[@"",@"",@"",@"",@""]];
    self.title = @"详情";
}

-(void)setUI {
    [self.view addSubview:self.XMTableview];
    self.XMTableview.height -= 50;
    self.XMTableview.estimatedRowHeight = 50;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.baseMutableDataArray.count + self.baseDataArray.count + 2;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        // 头像
        DetialHeadCell * cell = [DetialHeadCell cellWithTalbelView:tableView];
        return cell;
    }
    if (indexPath.row == self.baseMutableDataArray.count + 1) {
        DetailButtonCell * cell = [DetailButtonCell cellWithTalbelView:tableView];
        return cell;
    }
    if (indexPath.row > 0 && indexPath.row <= self.baseMutableDataArray.count) {
        DetailImageCell * cell = [DetailImageCell cellWithTalbelView:tableView];
        return cell;
    }
    DetailPinlunCell * cell = [DetailPinlunCell cellWithTalbelView:tableView];
    cell.contentLable.text = self.baseDataArray[indexPath.row - self.baseMutableDataArray.count - 2];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewAutomaticDimension;
}

@end
